<?php

namespace Plugin\ProductCategory\Controllers;

use Beike\Models\Product;
use Beike\Shop\Http\Controllers\Controller;
use Illuminate\Http\Request;

class ProductCategoryController extends Controller
{


    public function batch(Request $request)
    {
        $products = Product::query()->whereIn('id', $request->ids)->get();
        foreach ($products as $product) {
            $product->categories()->sync($request->categories ?? []);
        }
        return json_success("success");
    }
}
